package com.ruoyi.performance.fixedtime;

import com.ruoyi.common.weChatRobot.template.QicqMailTemplate;
import com.ruoyi.common.weChatRobot.utils.WechatRobotUtil;
import com.ruoyi.performance.domain.SysMonthlyData;
import com.ruoyi.performance.service.ISysMonthlyDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;


@Component
public class MonthlyReminderTask extends WechatRobotUtil{
    @Autowired
    private ISysMonthlyDataService sysMonthlyDataService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private QicqMailTemplate qicqMailTemplate;

    // 用来做每月给老师推送填报考核的定时消息
    @Scheduled(cron = "0 0 0 30 * ?") // 每月30号0点执行
    public void remindMonthlyData() {
        // 提醒讲师和技术老师的逻辑
        ArrayList<String> strings = new ArrayList<>();
        strings.add("15608179817");
        sendTextMessage("请各位老师填写月度数据表",strings);
        qicqMailTemplate.sendMail("945320647@qq.com","月度考核","月初请各位老师自行填写自我评价!");
    }

    // 用来生成每月考核的定时消息
    @Scheduled(cron = "0 0 0 1 * ?") // 每月1号0点执行
    public void assessmentScores() {
        List<SysMonthlyData>result=sysMonthlyDataService.list();
        redisTemplate.opsForSet().add("monthly_assessment",result);

    }
}
